package modellayer;

import java.util.ArrayList;
import java.util.List;


/**
 * This container-class can hold all the order-lines
 * normally belonging to an order and calculate a total
 * based on these order-lines. 
 * @author (ucn-1semprojekt-dm78-gruppe1)
 *
 */
public class OrderLines
{
	private List<OrderLine> orderLineList;
	
	public OrderLines()
	{
		orderLineList = new ArrayList<OrderLine>();
	}
	
	/**
	 * Calculates the total based on all the subtotals
	 * from each order-line
	 * @return the total
	 */
	public double getTotal()
	{
		double total = 0;
		for (OrderLine line : orderLineList)
		{
			total += line.getSubTotal();
		}
		return total;
	}

	/**
	 * Calculates the discounted total based on all
	 * the discounted subtotals from each order-line
	 * @return the discountTotal
	 */
	public double getDiscountTotal()
	{
		double discountTotal = 0;
		for (OrderLine line : orderLineList)
		{
			discountTotal += line.getDiscountSubtotal();
		}
		return discountTotal;
	}

	/**
	 * One intent is to pass this to a control-view GUI
	 * to do some manipulation by user
	 * @return the orderLineList
	 */
	public List<OrderLine> getOrderLineList()
	{
		return orderLineList;
	}

}
